package cast;
class Animal{}
class Dog extends Animal{}
class Cat extends Animal{}
public class TestCast{
	public static void main(String[]args){
		Animal a = new Dog();
		Dog d = (Dog)a;
		//Cat c = new Cat();
		//Dog d1 = (Dog)c;
		Animal c = new Cat();
		if(c instanceof Dog){
			Dog d1 = (Dog)c;
		}
		if(c instanceof Cat){
			System.out.println("cat");
		}
		if(c instanceof Animal){
			System.out.println("animal");
		}
		if(c instanceof Object){
			System.out.println("object");
		}
		if(c instanceof Dog){
			System.out.println("cat is a dog");
		}
	}
}